package com.wesley.growth.spring.config;

import com.wesley.growth.spring.CustomInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * CustomWebConfig
 *
 * @author WangPanYong
 * @since 2021/04/23 14:27
 */
@Configuration
public class CustomWebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 1.加入的顺序就是拦截器执行的顺序，
        // 2.按顺序执行所有拦截器的preHandle
        // 3.所有的preHandle 执行完再执行全部postHandle 最后是postHandle
        registry.addInterceptor(new CustomInterceptor())
                .addPathPatterns("/hello/**");
    }
}
